const express = require('express');
const NewsController = require('../../controller/admin/NewsController');
var NewsRouter = express.Router();
const multer = require('multer');
//尽量放在静态文件夹下  public/avataruploads/ 静态目录下自动生成
const upload = multer({ dest: 'public/newsuploads/' });
//创建内容接口
NewsRouter.post('/adminapi/news/add', upload.single('file'), NewsController.add);
//获取内容列表
NewsRouter.get('/adminapi/news/list/user/:aid', NewsController.postList);
//编辑更新单个内容
NewsRouter.post('/adminapi/news/list', upload.single('file'), NewsController.updateList);
//获取单个文章
NewsRouter.get('/adminapi/news/list/:id', NewsController.getList);
//修改发布状态
NewsRouter.put('/adminapi/news/publish', NewsController.publish);
//删除文章
NewsRouter.delete('/adminapi/news/list/:id', NewsController.delList);

module.exports = NewsRouter;
